package de.uni.muenster.idw2.threads;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

import de.uni.muenster.idw2.data.DrawableObject;

import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;

public class DongleLoader implements Runnable{
	
	private DrawableObject bitmap;
	private String path;

	public DongleLoader(DrawableObject bitmap, String path){
		this.bitmap = bitmap;
		this.path = path;
		
	}

	@Override
	public void run() {
		try {
			Drawable img = Drawable.createFromStream((InputStream) new URL(path).getContent(), "draw");
			bitmap.setDrawable(img);
		} catch (MalformedURLException e) {
			Log.e("wichtig", e.toString());
		} catch (IOException e) {
			Log.e("wichtig", e.toString());
		} catch (OutOfMemoryError e) {
			Log.e("wichtig", e.toString());
		}catch (Throwable e) {
			Log.e("wichtig", e.toString());
		}
	}

}
